unit uLogInfo;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs,BaseForm, cxGraphics, cxControls,
  cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore, dxSkinBlack, dxSkinBlue,
  dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide,
  dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
  dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
  dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins,
  dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
  dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinPumpkin, dxSkinSeven,
  dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver,
  dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld,
  dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint,
  dxSkinXmas2008Blue, cxStyles, dxSkinscxPCPainter, cxCustomData, cxFilter,
  cxData, cxDataStorage, cxEdit, cxNavigator, Data.DB, cxDBData, cxContainer,
  cxGroupBox, cxGridLevel, cxGridCustomTableView, cxGridTableView,
  cxGridDBTableView, cxClasses, cxGridCustomView, cxGrid, Datasnap.DBClient,
  ClientRowSet, Vcl.ComCtrls, dxCore, cxDateUtils, cxButtonEdit, cxTextEdit,
  cxMaskEdit, cxDropDownEdit, cxCalendar, Vcl.StdCtrls, Vcl.Menus, cxButtons,
  Vcl.ActnList, Vcl.ExtCtrls, cxMemo;

type
  TFrmLogInfo = class(TBaseForm)
    dsLogInfo: TDataSource;
    crsLogInfo: TClientRowSet;
    crsLogInfoLOGID: TStringField;
    crsLogInfoTABLENAME: TStringField;
    crsLogInfoKEYFIELD: TStringField;
    crsLogInfoKEYVALUE: TStringField;
    crsLogInfoLOGTIME: TDateTimeField;
    crsLogInfoSYS_ACCOUNT: TStringField;
    crsLogInfoUSERID: TStringField;
    crsLogInfoACTIONNAME: TStringField;
    crsLogInfoACTIONCAPTION: TStringField;
    crsLogInfoUSERNAME: TStringField;
    crsLogInfoEMPNO: TStringField;
    crsLogInfoOPERATION: TStringField;
    crsLogInfoIP_ADDRESS: TStringField;
    crsLogInfoMAC_ADDRESS: TStringField;
    crsLogInfoCREATE_DT: TStringField;
    crsLogInfoGROUP_CODE: TStringField;
    crsLogInfoOP_NODE: TStringField;
    GrdBasic: TcxGrid;
    tvBasic: TcxGridDBTableView;
    tvBasicCONTENT: TcxGridDBColumn;
    tvBasicOPERATION: TcxGridDBColumn;
    tvBasicTABLENAME: TcxGridDBColumn;
    tvBasicKEYFIELD: TcxGridDBColumn;
    tvBasicKEYVALUE: TcxGridDBColumn;
    tvBasicLOGTIME: TcxGridDBColumn;
    tvBasicEMPNO: TcxGridDBColumn;
    tvBasicUSERNAME: TcxGridDBColumn;
    tvBasicOP_NODE: TcxGridDBColumn;
    tvBasicACTIONNAME: TcxGridDBColumn;
    lvEXP_COMP: TcxGridLevel;
    cxGroupBox1: TcxGroupBox;
    Label5: TLabel;
    Label2: TLabel;
    edtDateFrom: TcxDateEdit;
    edtDateTo: TcxDateEdit;
    Label4: TLabel;
    edtEmpNo: TcxButtonEdit;
    Label3: TLabel;
    edtNodeNo: TcxButtonEdit;
    pnlInfo: TPanel;
    ActionList: TActionList;
    actSearch: TAction;
    cxButton2: TcxButton;
    crsLogInfoCONTENT: TStringField;
    edtInputor: TcxTextEdit;
    Label1: TLabel;
    procedure edtNodeNoPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure edtEmpNoPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure actSearchExecute(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure InitForm;
  end;

var
  FrmLogInfo: TFrmLogInfo;

implementation

{$R *.dfm}

uses uSelectEmp, uSelectInfo, ucommFunction;

procedure TFrmLogInfo.actSearchExecute(Sender: TObject);
var
  sqltext:string;
  sNode:string;
begin
  pShowWait(pnlInfo,True);
  sqltext:='select * from  sys_loginfo where group_code='+QuotedStr(UserInfo.groupCode);
  sqltext:=sqltext+' and CREATE_DT>='+QuotedStr(edtDateFrom.Text)+' and CREATE_DT<='+QuotedStr(edtDateTo.Text+' 23:59:59');
  if Trim(edtEmpNo.Text)<>'' then
    sqltext:=sqltext+' and empno='+QuotedStr(edtEmpNo.Text);
  if Trim(edtInputor.Text)<>'' then
    sqltext:=sqltext+' and KEYVALUE='+QuotedStr(edtInputor.Text);
  if Trim(edtNodeNo.Text)<>'' then
  begin
    sNode:=fGetNodeList(edtNodeNo.Text);
    sqltext:=sqltext+' and op_node in '+sNode;
  end;
  sqltext:=sqltext+' order by CREATE_DT desc';
  OpenDataSet(sqltext,crsLogInfo);
  pShowWait(pnlInfo,False);
end;

procedure TFrmLogInfo.edtEmpNoPropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
var
  empNo: string;
begin
  empNo := SelectEmpShow;
  if empNo <> '' then
    edtEmpNo.Text := empNo;
end;

procedure TFrmLogInfo.edtNodeNoPropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
var
  nodeNo: string;
begin
  nodeNo := SelectInfoNodeShow;
  if nodeNo <> '' then
    edtNodeNo.Text := nodeNo;
end;

procedure TFrmLogInfo.InitForm;
begin
  edtDateFrom.Date := Date;
  edtDateTo.Date := Date;
  if not userInfo.isCenter then
  begin
    edtNodeNo.Text := userInfo.nodeNo;
    edtNodeNo.Enabled:=False;
  end;
  actSearch.Execute;
end;

end.
